#include "timecode.h"
#include <QStringList>
TimeCode::TimeCode()
{

}


int TimeCode::timestampToFrame(const QString stamp, const int fps)
{
  QStringList ns = stamp.split(":");
  double hh = ns[0].toDouble();
  double mm = ns[1].toDouble();
  double ss = ns[2].toDouble();
  double seconds = (hh * 60 * 60) + (mm * 60) + ss;
  double ff = seconds * fps;
  int frames = qRound64(ff);
  return frames;
}

QList<int> TimeCode::frameToTimeAbout(const int frame, const int fps)
{
  int seconds = frame / fps;
  int ss = seconds % 60;
  int minutes = seconds / 60;
  int mm = minutes % 60;
  int hh = minutes / 60;
  return {hh, mm, ss};
}
